from datetime import datetime

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, DateTime, Integer
from db import engine

# 得到默认Base基类
Base = declarative_base()


class Message(Base):
    __tablename__ = "message"
    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(60), comment="昵称", nullable=False)
    phone = Column(String(11), comment="时间", nullable=False)
    body = Column(String(200), comment="内容", nullable=False)
    create_at = Column(DateTime, default=datetime.now, comment="创建时间")


class User(Base):
    __tablename__ = "user"
    id = Column(Integer, primary_key=True, index=True)
    login_name = Column(String(20), comment="登录用户名", nullable=False)
    login_pwd = Column(String(32), comment="登录密码", nullable=False)
    create_time = Column(DateTime, default=datetime.now, comment="创建时间")


if __name__ == '__main__':
    Base.metadata.create_all(engine)
